package com.armani.service.impl;

import com.armani.entity.Address;
import com.armani.mapper.AddressMapper;
import com.armani.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ProjectName: armani
 * @Package: com.armani.service.impl
 * @ClassName: AddressServiceImpl
 * @Description: TODO
 * @Author: Roc
 * @Date: 2021/11/30 18:02
 * @Version: 1.0
 **/
@Service
public class AddressServiceImpl implements AddressService {

    @Resource
    private AddressMapper addressMapper;
    @Override
    public List<Address> ListSearch(String shopUser, Integer userId, String phone, String province, String city, String district, String detail, Integer startRow, Integer limit) {
        return addressMapper.ListSearch(shopUser,userId,phone,province,city,district,detail,startRow,limit);
    }

    @Override
    public Integer getCount(String shopUser, Integer userId, String phone, String province, String city, String district, String detail) {
        return addressMapper.getCount(shopUser,userId,phone,province,city,district,detail);
    }

    @Override
    @Transactional
    public Integer insert(String shopUser, Integer userId, String phone, String province, String city,
                          String district, String detail) {
        return addressMapper.insert(shopUser,userId,phone,province,city,district,detail);
    }

    @Override
    @Transactional
    public Integer update(String shopUser, Integer userId, String phone,
                          String province, String city, String district, String detail, Integer id) {
        return addressMapper.update(shopUser,userId,phone,province,city,district,detail,id);
    }

    @Override
    @Transactional
    public Integer delete(Integer id) {
        return addressMapper.delete(id);
    }

    /**
     * 查询用户地址
     *
     * @param userId 用户id
     * @return 用户地址列表
     */
    @Override
    public List<Address> searchByUserId(Integer userId) {
        List<Address> addresses=addressMapper.searchByUserId(userId);
        return addresses;
    }
}
